#ifndef GSENSOR_H_
#define GSENSOR_H_

#include <stdint.h>
#include <stddef.h>

#define GSENSOR_DEVICE	0x30//0x7A

typedef struct
{
	int16_t AcceX;
	int16_t AcceY;
	int16_t AcceZ;
}gSensor_data;

uint8_t gSensor_Init(void);
uint8_t gSensor_Readxyz(gSensor_data *sample);
uint8_t gSensor_WriteRegister(uint8_t reg, uint8_t data);
uint8_t gSensor_ReadRegister(uint8_t reg, uint8_t* data);
uint8_t gSensor_ReadData(uint8_t  reg, size_t len, uint8_t* data);
uint8_t gSensor_enable_interrupt(uint16_t flag);

#define GSENSOR_ADDR        0x18

#define GSENSOR_CHIP_ID 	0x00
#define GSENSOR_DATA_X_L 	0x02
#define GSENSOR_DATA_X_H 	0x03
#define GSENSOR_DATA_Y_L 	0x04
#define GSENSOR_DATA_Y_H 	0x05
#define GSENSOR_DATA_Z_L 	0x06
#define GSENSOR_DATA_Z_H 	0x07
#define GSENSOR_INT_STATE_0 0x09
#define GSENSOR_INT_STATE_1 0x0A
#define GSENSOR_G_RANGE     0x0F
#define GSENSOR_BANDWIDTHS  0x10
#define GSENSOR_PWR_MODE    0x11
#define GSENSOR_INT_CFG_0   0x16
#define GSENSOR_INT_CFG_1   0x17
#define GSENSOR_INT_MAP_0   0x1A
#define GSENSOR_INT_MAP_1   0x1B


#define GSENSOR_FLAT_INT_STATE 0x8000
#define GSENSOR_ORIENT_INT_STATE 0x4000
#define GSENSOR_S_TAP_INT_STATE 0x2000
#define GSENSOR_D_TAP_INT_STATE 0x1000
#define GSENSOR_SLOPE_INT_STATE 0x0400
#define GSENSOR_HIGH_INT_STATE 0x0300
#define GSENSOR_LOW_INT_STATE 0x0100
#define GSENSOR_DATA_INT_STATE 0x0080




#endif /* GSENSOR_H_ */
